package com.hwadee.teachingprocessmanagementsystem.config;

import com.hwadee.teachingprocessmanagementsystem.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 配置拦截器
 * @Author: Jukomu
 * @Package: org.csu.mypetstore.config
 * @Project: MyPetStore-SSM
 * @name: InterceptorConfig
 * @Date: 2024/4/1 1:45
 * @Filename: InterceptorConfig
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JWTInterceptor jwtInterceptor(){
        return new JWTInterceptor();
    }

    /**
     * 添加拦截器配置
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加JWT拦截器
        registry.addInterceptor(jwtInterceptor())
                // 指定拦截器的URL路径
                .addPathPatterns("/**");
    }
}
